#!/bin/bash

# Copyright 2014 Intel Corporation, All Rights Reserved.

# Licensed under the Apache License, Version 2.0 (the"License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#  http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.


function _create_pool() {
    local pool_name=$1
    #local temp_pool=${pool_name:4}
    local cnt=`ceph osd lspools| grep $pool_name | wc -l`
    if [[ $cnt -eq 0 ]]; then
        rados mkpool $pool_name
    fi
}

function _del_user() {
    local user_name=$1
    local cnt=`ceph auth list| grep $user_name | wc -l`
    if [[ $cnt -gt 0 ]]; then
        ceph auth del $user_name
    fi
}

function _del_pool() {
    local pool_name=$1
    local cnt=`ceph osd lspools | grep $pool_name | wc -l`
    if [[ $cnt -gt 0 ]]; then
        rados --pool $pool_name rmpool $pool_name $pool_name --yes-i-really-really-mean-it
    fi
}
